
package com.trydofor.a9task.base.code.sysd;

import com.trydofor.a9task.base.code.help.Code;
import com.trydofor.a9task.base.code.help.CodeBuilder;
import com.trydofor.a9task.base.sys.anno.SystemData;

/**
 * @author : Shi Rongjiu (www.trydofor.com)
 * @date : 2012-12-23
 * @see :
 */

public abstract class PassChar {

    public final static int    $   = GroupRoot.$PASS_CHAR$;
    public final static String _   = "PASS_CHAR$";
    @SystemData
    public final static Code   $_  = CodeBuilder.code(GroupRoot.$, $, _)
   	                                            .lang(Language.$EN_US, "password char", "char for password")
   	                                            .lang(Language.$ZH_CN, "密码字符", "密码中使用的字符")
                                                .done();
    
    public final static int    $DIGIT  = $ + 1;
    public final static String _DIGIT  = "PASS_CHAR$DIGIT";
    @SystemData
    public final static Code   DIGIT   = CodeBuilder.code($, $DIGIT, _DIGIT)
   	                                               .lang(Language.$EN_US, "digit", "[0-9]")
   	                                               .lang(Language.$ZH_CN, "数字", "[0-9]")
                                                   .done();
    public final static int    $LOWER  = $ + 2;
    public final static String _LOWER  = "PASS_CHAR$LOWER";
    @SystemData
    public final static Code   LOWER   = CodeBuilder.code($, $LOWER, _LOWER)
   	                                               .lang(Language.$EN_US, "lower", "[a-z]")
   	                                               .lang(Language.$ZH_CN, "小写字母", "[a-z]")
                                                   .done();
    public final static int    $UPPER  = $ + 3;
    public final static String _UPPER  = "PASS_CHAR$UPPER";
    @SystemData
    public final static Code   UPPER   = CodeBuilder.code($, $UPPER, _UPPER)
   	                                               .lang(Language.$EN_US, "upper", "[A-Z]")
   	                                               .lang(Language.$ZH_CN, "大写字母", "[A-Z]")
                                                   .done();
    public final static int    $PUNCT  = $ + 4;
    public final static String _PUNCT  = "PASS_CHAR$PUNCT";
    @SystemData
    public final static Code   PUNCT   = CodeBuilder.code($, $PUNCT, _PUNCT)
   	                                               .lang(Language.$EN_US, "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~")
   	                                               .lang(Language.$ZH_CN, "符号", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~")
                                                   .done();
    public final static int    $OTHER  = $ + 5;
    public final static String _OTHER  = "PASS_CHAR$OTHER";
    @SystemData
    public final static Code   OTHER   = CodeBuilder.code($, $OTHER, _OTHER)
   	                                               .lang(Language.$EN_US, "other", "not [DIGIT|LOWER|UPPER|PUNCT]")
   	                                               .lang(Language.$ZH_CN, "其他", "非数字，字母和符号")
                                                   .done();

    ///////////////////////
    /**
     * true if id is the system default data
     * @param id the code id
     * @return
     */
    public final static boolean in(int id){
        if($DIGIT == id) return true;
        if($LOWER == id) return true;
        if($UPPER == id) return true;
        if($PUNCT == id) return true;
        if($OTHER == id) return true;
        return false;
    }
    
    /**
     * get the code by id
     * @param id the code id
     * @return
     */
    public final static Code of(int id){
        if($DIGIT == id) return DIGIT;
        if($LOWER == id) return LOWER;
        if($UPPER == id) return UPPER;
        if($PUNCT == id) return PUNCT;
        if($OTHER == id) return OTHER;
        return null;
    }
    
    /**
     * get the code by key
     * @param id the code key
     * @return
     */
    public final static Code of(String key){
        if(key == null) return null;
        if(_DIGIT.equals(key)) return DIGIT;
        if(_LOWER.equals(key)) return LOWER;
        if(_UPPER.equals(key)) return UPPER;
        if(_PUNCT.equals(key)) return PUNCT;
        if(_OTHER.equals(key)) return OTHER;
        return null;
    }
}
